@extends('layout')
@section('content')
    <article class="page-container">
        <form action="{{ url('nonPublicVersion/gameConfig',$oldData->id) }}" method="PUT" class="form form-horizontal" id="form-member-add">
            {{ csrf_field() }}
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>游戏名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ $oldData->game_id }}" placeholder="" id="name" name="name">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>游戏简写（key）：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ $oldData->key }}" placeholder="" id="key" name="key">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    <span class="c-red">*</span>游戏支付回调地址：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ $oldData->callback_url }}" placeholder="" id="callback_url" name="callback_url">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">
                    版本：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ $oldData->version }}" placeholder="" id="version" name="version">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">备注：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="note" cols="" rows="" class="textarea" placeholder=""
                              onKeyUp="$.Huitextarealength(this,600)">{{ $oldData->note }}</textarea>
                    <p class="textarea-numberbar"><em class="textarea-length">0</em>/600</p>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>

    </article>
@endsection
@section('script')
    <script type="application/javascript">
        $(function () {
            $("#form-member-add").validate({
                rules:{
                    name:{
                        required:true,
                        minlength:1,
                        maxlength:50
                    },
                    key:{
                        required:true,
                    },
                    callback_url:{
                        required:true,
                    },
                },
                onkeyup:false,
                focusCleanup:true,
                success:"valid",
                submitHandler:function(form){
                    var url = $(form).attr('action');
                    request(url,function (data) {
                        if (data.code != 0){
                            layer.msg(data.msg);
                            return ;
                        }
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.$('#btn-refresh').click();
                        parent.layer.close(index);
                    },$(form).serialize(),'PUT');
                }
            });
        })
    </script>
@endsection